package com.windfone.web;

import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.springframework.web.context.support.WebApplicationContextUtils;

import com.windfone.model.Fittingtype;
import com.windfone.service.FittingService;

public class PeijianTag extends TagSupport {
	/** serialVersionUID */
	private static final long serialVersionUID = 1L;
	private FittingService fittingService;
	private List<Fittingtype> fittingtype;
	private String attriName;
	private int fittingtypebaseId =-1;
 	
	public FittingService getFittingService() {
		return fittingService;
	}


	public List<Fittingtype> getFittingtype() {
		return fittingtype;
	}


	public String getAttriName() {
		return attriName;
	}


	public int getFittingtypebaseId() {
		return fittingtypebaseId;
	}


	public void setFittingService(FittingService fittingService) {
		this.fittingService = fittingService;
	}


	public void setFittingtype(List<Fittingtype> fittingtype) {
		this.fittingtype = fittingtype;
	}


	public void setAttriName(String attriName) {
		this.attriName = attriName;
	}


	public void setFittingtypebaseId(int fittingtypebaseId) {
		this.fittingtypebaseId = fittingtypebaseId;
	}


	public int doStartTag() throws JspException {
		ServletContext sc = pageContext.getServletContext();
		if ( fittingService == null )
			fittingService = (FittingService) WebApplicationContextUtils.getWebApplicationContext(sc).getBean("fittingService");
		if ( fittingtypebaseId != -1 ){
			fittingtype =fittingService.getFittingTypeByBaseTypeId(fittingtypebaseId);
			this.pageContext.setAttribute(attriName,fittingtype);
			fittingtypebaseId = -1;
		}
		return(SKIP_BODY);
 
	}
}
